package com.qiku.controller;

import com.qiku.constants.SystemConstants;
import com.qiku.entity.Comment;
import com.qiku.entity.ResponseResult;
import com.qiku.service.CommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/comment")
@Api(description = "评论相关接口")
public class CommentController {
    @Autowired
    private CommentService commentService;

    /**
     * 文章评论列表查询
     * @param articleId
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("/commentList")
    @ApiOperation(value = "文章评论列表查询",notes = "文章评论列表查询")
    //参数描述
    @ApiImplicitParams({
            @ApiImplicitParam(name = "articleId",value ="文章id"),
            @ApiImplicitParam(name = "pageNum",value ="页号"),
            @ApiImplicitParam(name = "pageSize",value ="每页条数")
    })
    public ResponseResult commentList(Long articleId,Integer pageNum,Integer pageSize){
        return commentService.commentList(SystemConstants
                .ARTICLE_COMMENT_TYPE,articleId,pageNum,pageSize);
    }

    @GetMapping("/linkCommentList")
    public ResponseResult linkCommentList(Long articleId,Integer pageNum,Integer pageSize){
        return commentService.commentList(SystemConstants.LINK_COMMENT_TYPE,null,pageNum,pageSize);
    }
    @PostMapping("/addComment")
    public ResponseResult addComment(@RequestBody Comment comment){
        return commentService.addComment(comment);
    }
}
